<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>vue</title>
    <script src='https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js'></script>
    <style>
        li {
            overflow: hidden;
            list-style: none;
            padding: 10px;
        }

        li img {
            float: left;
            width: 100px;
        }
    </style>
</head>

<body>
    <div id='app'>
        <button @click="handleFetch">即将上映</button>
        <ul>
            <li v-for="data in arr" :key="data.filmId">
                <img :src="data.poster" />
                {{data.name}}
            </li>
        </ul>

    </div>
</body>
<script>
    // 数据来源：
    //     卖座 https://m.maizuo.com/v5/?co=mzmovie#/films/nowPlaying
    let vm = new Vue({
        el: '#app',
        data: {
            arr: []
        },
        methods: {
            handleFetch() {
                fetch("./json/maizuo.json")
                    .then(res => res.json())
                    .then(res => {
                        console.log(res);
                        console.log(res.data.films);
                        this.arr = res.data.films;
                    })
                    .catch(err => {
                        console.log(err);
                    });
            }
        }
    });
</script>

</html>